﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

public partial class LoginUser : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(Request.QueryString["Error"] == "False")
        {
            Label_Error.Text = "当前用户不存在";
            Label_Error.ForeColor = Color.Red;
        }
    }
    protected void Button_Confirm_Click(object sender, EventArgs e)
    {
       //Check if the user is ok
       string UserName = TextBox_UserName.Text;
       string Password = TextBox2.Text;
       //validate user right by database 
       bool Result = ((KaohePage)Page).MainLogic.ValidateUser(UserName, Password);
       //redirect will return the function imediately.
       if(Result)
       {
           Response.Redirect("default.aspx");
       }
       else
       {
           Response.Redirect("LoginPage.aspx" + "?Error=" + Result.ToString());
       }
       
    }
}
